<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<link rel="stylesheet" href="__ADMIN_STATICS__/bootstrap/dist/css/bootstrap.css" type="text/css" />
	<link rel="stylesheet" href="__ADMIN_STATICS__/animate.css/animate.css" type="text/css" />
	<link rel="stylesheet" href="__ADMIN_STATICS__/font-awesome/css/font-awesome.min.css" type="text/css" />
	<link rel="stylesheet" href="__ADMIN_STATICS__/simple-line-icons/css/simple-line-icons.css" type="text/css" />
	<link rel="stylesheet" href="__ADMIN_STATICS__/bootstrap-editable/css/bootstrap-editable.min.css" type="text/css" />
	<link rel="stylesheet" href="__ADMIN_STATICS__/app/css/font.css" type="text/css" />
	<link rel="stylesheet" href="__ADMIN_STATICS__/app/css/app.css" type="text/css" />
</head>
<body>
<div class="wrapper-md">
   <div class="panel panel-default">
    <div class="panel-heading">
    	<a href="{:U('Admin/Index/welcome')}"><i class="fa fa-home"></i>&nbsp;首页&nbsp;</a>&gt;&nbsp;&nbsp;分类列表
    	<a href="{:U('Admin/GoodsCategory/add', array('pid'=>0))}" class="btn btn-primary btn-xs menu-add pull-right">添加分类</a>
    </div>
    <div class="table-responsive">
		<table class="table table-bordered table-striped table-hover table-condensed b-t b-light">
			<thead>
				<tr>
				<th>ID</th>
				<th>分类名</th>
				<th width="80">排序</th>
				<th width="70">推荐</th>
				<th width="190">操作</th>
				</tr>
			</thead>
			<tbody>
				<foreach name="data" item="v">
				<tr menuId="${menu.id}" pid="${menu.parentId}">
					<td>{$v['id']}</td>
					<td><span class="menu-name">{$v['_name']}</span></td>
					<td><span class="menu-sort">{$v['order_number']}</span></td>
					 <td class="text-center" data-id="{$v['id']}" data-type="is_recommend" onclick="edit(this)">
                        <a href="javascript:void(0);" class="{$v['is_recommend'] == 1 ? 'active' : ''}"><i class="fa fa-check text-success text-active"></i><i class="fa fa-times text-danger text"></i></a>
                    </td>
					<td>
						<a href="{:U('Admin/GoodsCategory/add', array('pid'=>$v['id']))}" class="btn btn-default btn-xs menu-addchild">添加子分类</a>
						<a href="{:U('Admin/GoodsCategory/edit', array('id'=>$v['id']))}" class="btn btn-info btn-xs menu-edit">修改</a>
						<a class="btn btn-danger btn-xs menu-delete" href="javascript:if(confirm('确定删除？'))location='{:U('Admin/GoodsCategory/delete',array('id'=>$v['id']))}'">删除</a>
					</td>
				</tr>
				</foreach>
			</tbody>
		</table>
    </div>
  </div>
</div>
<script src="__ADMIN_STATICS__/jquery/jquery.min.js"></script>
<script src="__ADMIN_STATICS__/bootstrap/dist/js/bootstrap.js"></script>
<script type="text/javascript">
function edit(obj) {
    var id = $(obj).attr('data-id');
    var type = $(obj).attr('data-type');
    var a = $(obj).find('a');
    var param = 0;
    if(a.hasClass('active')){
        param = 0;
    }else{
        param = 1;
    }
    $.ajax({
        url : "{:U('Admin/GoodsCategory/editAjax')}",
        data : {id : id, type : type, param : param},
        dataType : "json",
        type : "post",
        success:function(data){
            if(data.code){
                a.toggleClass('active');
            }
        }
    });
}
</script>
</body>
</html>
